package com.rock.upms.svc.model.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.rock.common.base.BaseModelService;
import com.rock.upms.model.UpmsLog;
import com.rock.upms.model.UpmsLogExample;
import com.rock.upms.svc.dao.model.mapper.UpmsLogMapper;
import com.rock.upms.api.model.service.IUpmsLogService;
import com.rock.upms.svc.model.service.impl.UpmsLogService;
import com.rock.pkp.api.IPrimaryKeyService;
import com.rock.common.util.StringUtil;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.rock.common.annotation.ANNBaseService;
import org.springframework.stereotype.Repository;

/**
 * 功能： UpmsLogService实现类 说明： Created by zhousq on 2018/8/1. 变更日志：
 * 
 */
@ANNBaseService
@Repository
@Service
public class UpmsLogService extends BaseModelService<UpmsLogMapper, UpmsLog, UpmsLogExample> implements IUpmsLogService {

	@Autowired
	UpmsLogMapper upmsLogMapper;
	@Autowired
	private IPrimaryKeyService primaryKeyService;

	/**
	 * 方法名：insert(UpmsLog record)<br>
	 * 功能： 自定义主键插入单条记录<br>
	 * 参数：record 实体对象 <br>
	 * 返回值：插入成功返回插入的主键，失败返回0
	 */
	@Override
	public int insert(UpmsLog record) {
		// 根据实体类名转换为数据库表名,null表示默认主键名为ID
		int pk = primaryKeyService.getPrimaryKey(StringUtil.toTableName(UpmsLog.class), null);
		record.setId(pk);
		int recordSize = upmsLogMapper.insert(record);
		if (recordSize > 0) {
			return pk;
		} else {
			return 0;
		}
	}

	/**
	 * 方法名：insertSelective(UpmsLog record)<br>
	 * 功能： 自定义主键插入单条记录<br>
	 * 参数：record 实体对象 <br>
	 * 返回值：插入成功返回插入的主键，失败返回0
	 */
	@Override
	public int insertSelective(UpmsLog record) {
		// 根据实体类名转换为数据库表名,null表示默认主键名为ID
		int pk = primaryKeyService.getPrimaryKey(StringUtil.toTableName(UpmsLog.class), null);
		record.setId(pk);
		int recordSize = upmsLogMapper.insertSelective(record);
		if (recordSize > 0) {
			return pk;
		} else {
			return 0;
		}
	}
}